package logic.weapons;

import logic.NodeController;
import logic.ships.Ship;

import com.jme.math.Vector3f;

public class WeaponFireController extends NodeController {
	
	private static final long serialVersionUID = 1L;
	
	protected final float LIFE_TIME = 5f;
	
	protected WeaponFire weaponFire;
	protected Vector3f dir;
	protected Ship ship;
	protected float lifeTime;
	
	public WeaponFireController(WeaponFire weaponFire, Ship ship, Vector3f dir) {
		super(1.5f, weaponFire);
		this.ship = ship;
		this.weaponFire = weaponFire;
		this.dir = dir;
				
		lifeTime = LIFE_TIME;
		
		weaponFire.lookAt(dir, Vector3f.UNIT_Y);
	}
	
	@Override
	public void extraUpdate(float time) {
		lifeTime -= time;
		if(lifeTime <= 0f) weaponFire.destroy();
	}
	
	public Vector3f getFireDirection() { return dir; }
	
	@Override
	protected void delayedUpdate(float time) {}
}